package cn.wxq.daily.empdailymgforserve.service.impl;

import cn.wxq.daily.empdailymgforserve.domain.SysRole;
import cn.wxq.daily.empdailymgforserve.mapper.SysRoleDao;
import cn.wxq.daily.empdailymgforserve.service.SysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class SysRoleServiceImpl implements SysRoleService {

    @Autowired
    private SysRoleDao sysRoleDao;

    @Override
    public List<SysRole> selectRoleAll() {
        return sysRoleDao.selectRoleAll();
    }

    /**
     * 条件查询
     * @param sysRole
     * @return
     */
    @Override
    public List<SysRole> findByPage(SysRole sysRole) {
        return sysRoleDao.findByPage(sysRole);
    }

    @Override
    public SysRole selectById(Integer roleId) {
        return sysRoleDao.selectById(roleId);
    }

    @Override
    public int update(SysRole sysRole) {
        return sysRoleDao.update(sysRole);
    }

    /**
     * 新增角色
     * @param role 角色信息
     * @return
     */
    @Override
    public int insertRole(SysRole role) {
        role.setCreateTime(new Date());
        role.setUpdateTime(new Date());
        return sysRoleDao.insertRole(role);
    }

    /**
     * 通过id删除角色
     * @param roleId 角色ID
     * @return
     */
    @Override
    public int deleteRoleById(Long roleId) {
        return sysRoleDao.deleteRoleById(roleId);
    }

    /**
     * 修改角色状态
     * @param role 角色信息
     * @return
     */
    @Override
    public int updateRoleStatus(SysRole role) {
        role.setUpdateTime(new Date());//设置修改时间
        return sysRoleDao.updateRole(role);
    }
}
